
import { Column, Entity, PrimaryColumn, JoinColumn, ManyToOne } from 'typeorm';
import { TeamEntity } from './team.entity';
import { TeacherEntity } from './teacher.entity';

@Entity('team_teacher', {
  comment: '队伍与志愿教师关联表',
  schema: 'public',
})
export class TeamTeacherEntity {
  @PrimaryColumn({ type: 'integer', name: 'team_id', comment: '队伍id' })
  teamId: number;

  @PrimaryColumn({ type: 'integer', name: 'teacher_id', comment: '志愿老师id' })
  teacherId: number;

  @Column({ type: 'integer', name: 'sort', default: null, comment: '次序' })
  sort: number;

  @Column({ type: 'integer', name: 'select_flag', default: 0, comment: '0表示没有被选中，1表示被选中，一个队伍只能有一个1' })
  selectFlag: number;


  @ManyToOne(() => TeacherEntity, (teacher) => teacher.teamTeachers)
  @JoinColumn({ name: 'teacher_id', referencedColumnName: 'teacherId' })
  teacher: TeacherEntity;

  @ManyToOne(() => TeamEntity, (team) => team.teamTeachers)
  @JoinColumn({ name: 'team_id', referencedColumnName: 'teamId' })
  team: TeamEntity;
}
